﻿#pragma once

#include "Ability/EditorAbilityModel.h"
#include "EditorOutputAbilityModel.m.h"


RCLASS()
class REditorOutputAbilityModel : public REditorAbilityModel
{
    ROBJECT

public:
    REditorOutputAbilityModel();

    void PostLoadFromAsset() override;

    virtual CString GetName() const override { return U"输出"; }

    void AddLine(const CString& InLine);
    TDelegate<void> OnLineNumChanged;
    void ClearLines();
    int64_t GetLineNum() const { return Lines.Num(); }
    const CString& GetLine(int64_t InIndex) const { return Lines[InIndex]; }

    
    RFIELD()
    float ScrollPercent = 0.f;

    bool IsAutoScroll() const { return bAutoScroll; }
    void ToggleAutoScroll() { bAutoScroll = !bAutoScroll; }
protected:

    int64_t InitialMemorySize = 1024;
    
    RFIELD()
    TVector<CString> Lines;

    //auto scroll to bottom
    //when new output added
    RFIELD()
    bool bAutoScroll = true;

    void OnPrint(const CString& InNewMessage);
};